<?php

namespace App\Admin\Controllers;

use App\Services\HardwareCategoryService;
use Slowlyo\OwlAdmin\Controllers\AdminController;

/**
 * 硬件分类
 *
 * @property HardwareCategoryService $service
 */
class HardwareCategoryController extends AdminController
{
	protected string $serviceName = HardwareCategoryService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('category_name', '分类名称'),
				amis()->TableColumn('xmodel', '模版格式'),
				amis()->TableColumn('category_remark', '分类备注'),
				amis()->TableColumn('created_at', admin_trans('admin.created_at'))->type('datetime')->sortable(),
				$this->rowActions('dialog')
			]);

		return $this->baseList($crud);
	}

	public function form($isEdit = false)
	{
		return $this->baseForm()->body([
			amis()->TextControl('category_name', '分类名称')->required(),
			amis()->TextareaControl('xmodel', '模版格式'),
			amis()->TextareaControl('category_remark', '分类备注'),
			amis()->NumberControl('sort_order', '排序'),
			
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('category_name', '分类名称')->static(),
			amis()->TextControl('category_remark', '分类备注')->static(),
			amis()->TextControl('editor_uid', '编辑人UID')->static(),
			amis()->TextControl('operator_uid', '操作人UID')->static(),
			amis()->TextControl('soft_delete', '软删除标识（0未删除，1已删除）')->static(),
			amis()->TextControl('sort_order', '排序')->static(),
			amis()->TextControl('xmodel', '模版格式')->static(),
			amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
			amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
		]);
	}
}